package com.zyp.test.test;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * @author zyp
 *         2017/12/25
 */

public class ImageMatrixView extends View {

    private Bitmap mBitmap;
    private Matrix mMatrix;

    public ImageMatrixView(Context context) {
        super(context);
        init();
    }

    public ImageMatrixView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public ImageMatrixView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }
    private void init(){
        mBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
        mMatrix = new Matrix();
        float values[] = new float[9];
        mMatrix.postTranslate(100,0);
       
        mMatrix.getValues(values);
        mMatrix.postRotate(90);
        mMatrix.getValues(values);
        mMatrix.postTranslate(100,0);
        System.out.println();
        //setImageMatrix(mBitmap, mMatrix);
    }

    private void setImageMatrix(Bitmap bitmap, Matrix matrix) {
        
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(mBitmap,mMatrix,null);
    }
}
